﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace vmlModel.Entities
{
    public class vmlSubPath 
    {
        public string subPathString {get;set;}
        public bool IsClosed
        {
            get {
                return subPathString.Contains(" x");
            }
        }
        public bool IsFilled
        {
            get
            {
                return !subPathString.Contains(" nf");
            }
        }
        public bool IsStroked
        {
            get
            {
                return !subPathString.Contains(" ns");
            }
        }

        public List<vmlPathCommand> PathCommands  {get;set;}
        public vmlSubPath(vmlPathShapeBase Father , string _subPathString)
        {
            subPathString = _subPathString;
            string[] cmds = _subPathString.Split(' ');
            PathCommands = new List<vmlPathCommand>();
            foreach (var item in cmds)
            {
                if (item != "" && item != "&")
                {
                    if (PathCommands.Count != 0 && PathCommands.Last().cmdPoints != null )
                    {
                        PathCommands.Add(new vmlPathCommand(Father, PathCommands.Last().LastPoint, item.Trim()));
                    }
                    else
                    {

                        PathCommands.Add(new vmlPathCommand(Father, new Point(0, 0), item.Trim()));
                    }
                }
            }
        }

    }
}
